<?php
namespace Admin\Controller;

class HospitalController extends CommonController{
    
    public function index(){
        //城市数组
        $this->assign('cityRow',D('HptCity')->getCityRow());
        
        $where = array();
        $where['id'] = array('neq',1);//不显示默认透析中心
        if(I('get.keywords')){
            $where['name'] = array('like','%'.I('get.keywords').'%');
        }
        $dataPage = D($this->controller)->getPager($where);
        $this->assign('list',$dataPage['data']);
        $this->assign('page',$dataPage['page']);
        $this->display();
    }
    
    public function edit(){
        if(IS_POST){
            if($res = D($this->controller)->saveData(I('post.'))){
                die('suc');
            }else{
                die('err');
            }
        }else{
            //城市数组
            $this->assign('cityRow',D('HptCity')->getCityRow());
            
            $id=I('get.id');
            if($id){
                $this->assign('vo',D($this->controller)->find($id));
            }
            $this->assign('upPageUrl',$_SERVER['HTTP_REFERER']);
            $this->display();
        }
    }
    
    public function getHptByCid(){
        $hptArr = array();
        $hptArr = D($this->controller)->where(array('cid'=>I('request.cid')))->select();
        echo json_encode($hptArr);die;
    }
    
}